package cn.lijiguo.concurrency.part1.ch04;

import java.util.Optional;

/**
 * ThreadSimpleAPI
 *
 * @author lijiguo
 * @date 2019/12/13 13:01
 */
public class ThreadSimpleApi {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            Optional.of("Hello").ifPresent(System.out::println);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "t1");

        t1.start();

        // 获取线程名称
        Optional.of(t1.getName()).ifPresent(System.out::println);
        // 获取线程ID
        Optional.of(t1.getId()).ifPresent(System.out::println);
        // 获取线程优先级
        Optional.of(t1.getPriority()).ifPresent(System.out::println);
    }
}
